import 'package:flutter/material.dart';
import 'package:get/get.dart';

import '../../common/index.dart';
import '../vm/eg_vm.dart';
import '../widgets/eg_list_widget.dart';

class EgGetxListV extends BaseGetXlistV<EgGetxListC> {
  EgGetxListV({super.key});
  @override
  EgGetxListC get controller => Get.put(EgGetxListC());
  @override
  Widget createListView(BuildContext context) {
    Widget body = GetBuilder<EgGetxListC>(
      builder: (controller) => EgListWidget(
        itemList: controller.vm.itemList,
        type: 1,
      ),
    );
    return body;
  }
}

class EgGetxListC extends BaseGetXListController {
  // --------- 公开属性  --------- //
  @override
  bool get safeAreatop => false;
  @override
  bool get isShowAppBar => false;

  // --------- 私有属性  --------- //
  EgVm vm = EgVm();
  // --------- 生命周期  --------- //

  // --------- 数据处理  --------- //

  @override
  configDefault() {
    super.configDefault();
    getNetWorkData(type: 3);
  }

  @override
  getNetWorkData({int? type, Map<String, dynamic>? info}) async {
    await vm.configListData(page: page, isShowLoad: type == 3);
    update();
    // 结束刷新状态
    pageState.value = endRefresh(type: type!, state: vm.pageState);
  }

  // --------- 触发事件  --------- //

  @override
  tapPlaceHoldWidgetMethod({required CommonPlaceHoldType placeHoldType}) {
    getNetWorkData(type: 3);
  }
}
